﻿using DevExpress.XtraReports.UI;
using System.Collections.Generic;
using DevicesView.Entity;
using System;
using System.IO;

namespace Devices.Print
{
    public class UniversalPrint : IPrint, DevicesView.Logic.Print.IPrintExpand
    {

        private Devices.PrintInfo pinfo;

        public PrintInfo PrintInfo
        {
            get
            {
                if (pinfo == null)
                    pinfo = new PrintInfo(true);
                return pinfo;
            }
            set { pinfo = value; }
        }
        public void Preview(List<Result> result)
        {
            LabReportA4 labReportA4 = new LabReportA4(result);
            labReportA4.ShowPreviewDialog();
        } 
        public void Preview(List<Result> result, string PrinterName)
        {
            LabReportA4 labReportA4 = new LabReportA4(result);
            labReportA4.ShowPreviewDialog();
        } 
        public void Print(List<Result> result)
        {
            LabReportA4 labReportA4 = new LabReportA4(result);
            labReportA4.Print();
        }

        public void Print(List<Result> result, string PrinterName)
        {
            LabReportA4 labReportA4 = new LabReportA4(result);
            labReportA4.Print(PrinterName);
        }

        public void PrintToPDF(string pdfPath, List<Result> result)
        {
            throw new NotImplementedException();
        }

        public Stream PrintToPDF(List<Result> result)
        {
            LabReportA4 labReportA4 = new LabReportA4(result);
            Stream sm = new MemoryStream();
            labReportA4.ExportToPdf(sm);
            return sm;
        }
    }

}
